/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package livro.frames;

import livro.control.BookFrameDadosSave;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import utilitarios.Validar;

/**
 *
 * @author Ar0n
 */
public class BookFrameCad extends javax.swing.JInternalFrame {

    /**
     * Creates new form BookFrame
     */
    public BookFrameCad() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTAutor = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jTTitulo = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jTEditora = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jTISBN = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jDesktop = new javax.swing.JDesktopPane();
        jTQuant = new javax.swing.JTextField();

        jTAutor.setPreferredSize(new java.awt.Dimension(0, 10));
        jTAutor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTAutorKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTAutorKeyReleased(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setText("<html>Título:<b color=\"red\">*</b></html>");
        jLabel19.setPreferredSize(new java.awt.Dimension(20, 15));

        jLabel20.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel20.setText("<html>Autor:<b color=\"red\">*</b></html>");
        jLabel20.setPreferredSize(new java.awt.Dimension(20, 15));

        jTTitulo.setPreferredSize(new java.awt.Dimension(0, 10));
        jTTitulo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTTituloKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTTituloKeyReleased(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel21.setText("<html>Editora:<b color=\"red\">*</b></html>");
        jLabel21.setPreferredSize(new java.awt.Dimension(20, 15));

        jTEditora.setPreferredSize(new java.awt.Dimension(0, 10));
        jTEditora.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTEditoraKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTEditoraKeyReleased(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel22.setText("<html>ISBN:<b color=\"red\">*</b></html>");
        jLabel22.setPreferredSize(new java.awt.Dimension(20, 15));

        jTISBN.setPreferredSize(new java.awt.Dimension(0, 10));
        jTISBN.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTISBNKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTISBNKeyReleased(evt);
            }
        });

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel24.setText("<html>Quantidade de Exemplares:<b color=\"red\">*</b></html>");
        jLabel24.setPreferredSize(new java.awt.Dimension(20, 15));

        jDesktop.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                jDesktopAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        jTQuant.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTQuant.setPreferredSize(new java.awt.Dimension(0, 10));
        jTQuant.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTQuantKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTQuantKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(110, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(jTQuant, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jTISBN, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jTEditora, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(jTAutor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(jTTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(217, 217, 217))))
            .addComponent(jDesktop)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(100, 100, 100)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTAutor, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTEditora, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTISBN, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTQuant, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 158, Short.MAX_VALUE)
                .addComponent(jDesktop, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jDesktopAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jDesktopAncestorAdded
       
        /**
         Não foi criado um método especifico para fazer está parte em cadastro, pois 
         * essa operação só sera feita uma vez nessa classe
         */        
        BookFrameDadosSave bookFrameSave = new BookFrameDadosSave();
        jDesktop.add(bookFrameSave);
        bookFrameSave.show();
        //retirando bordas do internalJframe
        ((BasicInternalFrameUI)bookFrameSave.getUI()).setNorthPane(null);
        bookFrameSave.setBorder(null);
        //pegando dimenções do JDesktop no qual ele esta encapsulado
        bookFrameSave.setBounds(0, 0, jDesktop.getWidth(), jDesktop.getHeight());
        bookFrameSave.setResizable(false);
        
    }//GEN-LAST:event_jDesktopAncestorAdded

    private void jTTituloKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTTituloKeyPressed
        Validar.validaTexto(jTTitulo, 50);
    }//GEN-LAST:event_jTTituloKeyPressed

    private void jTTituloKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTTituloKeyReleased
        Validar.validaTexto(jTTitulo, 50);
    }//GEN-LAST:event_jTTituloKeyReleased

    private void jTAutorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTAutorKeyPressed
         Validar.validaTexto(jTAutor, 50);
    }//GEN-LAST:event_jTAutorKeyPressed

    private void jTAutorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTAutorKeyReleased
         Validar.validaTexto(jTAutor, 50);
    }//GEN-LAST:event_jTAutorKeyReleased

    private void jTEditoraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTEditoraKeyPressed
         Validar.validaTexto(jTEditora, 50);
    }//GEN-LAST:event_jTEditoraKeyPressed

    private void jTEditoraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTEditoraKeyReleased
         Validar.validaTexto(jTEditora, 50);
    }//GEN-LAST:event_jTEditoraKeyReleased

    private void jTISBNKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTISBNKeyPressed
        Validar.validaNum(jTISBN, 13);
    }//GEN-LAST:event_jTISBNKeyPressed

    private void jTISBNKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTISBNKeyReleased
        Validar.validaNum(jTISBN, 13);
    }//GEN-LAST:event_jTISBNKeyReleased

    private void jTQuantKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTQuantKeyPressed
        Validar.validaNum(jTQuant, 4);
    }//GEN-LAST:event_jTQuantKeyPressed

    private void jTQuantKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTQuantKeyReleased
        Validar.validaNum(jTQuant, 3);
    }//GEN-LAST:event_jTQuantKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static javax.swing.JDesktopPane jDesktop;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel24;
    public javax.swing.JTextField jTAutor;
    public javax.swing.JTextField jTEditora;
    public javax.swing.JTextField jTISBN;
    public javax.swing.JTextField jTQuant;
    public javax.swing.JTextField jTTitulo;
    // End of variables declaration//GEN-END:variables
    //atributos
    private static boolean estado;           
    //métodos
    public boolean getEstado(){
        return estado;
    }
    public void setEstado(boolean estado){
        this.estado = estado;
    }
    
}
